package com.zgxt.demo.service.impl;


import com.zgxt.demo.entity.DirectoryData;
import com.zgxt.demo.entity.ParentDirectory;
import com.zgxt.demo.entity.SecondDirectory;
import com.zgxt.demo.mapper.DirectoryMapper;
import com.zgxt.demo.service.DirectoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DirectoryServiceImpl implements DirectoryService {

    @Autowired
    DirectoryMapper directoryMapper;


    @Override
    public List<DirectoryData> directoryList(Integer pid) {
        return directoryMapper.directoryList(pid);
    }

    @Override
    public List<DirectoryData> s_directoryList(Integer sid) {
        return directoryMapper.s_directoryList(sid);
    }

    @Override
    public List<ParentDirectory> parentDirectoryList() {
        return directoryMapper.parentDirectoryList();
    }

    @Override
    public List<SecondDirectory> secondDirectoryList(Integer pid) {
        return directoryMapper.secondDirectoryList(pid);
    }

    @Override
    public Map<String, Object> directoryListAll(Integer pageIndex, Integer pageSize, String name) {
        Map<String, Object> map=new HashMap<>();
        map.put("data",directoryMapper.directoryListAll(pageIndex,pageSize,name));
        map.put("count",directoryMapper.directoryCount(name));
        return map;
    }

    @Override
    public Map<String, Object> s_directoryListAll(Integer pageIndex, Integer pageSize, String name) {
        Map<String, Object> map=new HashMap<>();
        map.put("data",directoryMapper.s_directoryListAll(pageIndex,pageSize,name));
        map.put("count",directoryMapper.s_directoryCount(name));
        return map;
    }

    @Override
    public Map<String, Object> parentDirectoryListAll(Integer pageIndex, Integer pageSize, String name) {
        Map<String, Object> map=new HashMap<>();
        map.put("data",directoryMapper.parentDirectoryListAll(pageIndex,pageSize,name));
        map.put("count",directoryMapper.parentDirectoryCount(name));
        return map;
    }

    @Override
    public Map<String, Object> secondDirectoryListAll(Integer pageIndex, Integer pageSize, String name) {
        Map<String, Object> map=new HashMap<>();
        map.put("data",directoryMapper.secondDirectoryListAll(pageIndex,pageSize,name));
        map.put("count",directoryMapper.secondDirectoryCount(name));
        return map;
    }

    @Override
    public Integer addParent(String name) {
        return directoryMapper.addParent(name);
    }

    @Override
    public Integer addSecond(String name, Integer pid) {
        return directoryMapper.addSecond(name,pid);
    }

    @Override
    public Integer addDirectory(String title, String link, Integer pid) {
        return directoryMapper.addDirectory(title,link,pid);
    }

    @Override
    public Integer addS_Directory(String title, String link, Integer sid) {
        return directoryMapper.addS_Directory(title,link,sid);
    }

    @Override
    public Integer deleteParent(String ids) {
        return directoryMapper.deleteParent(ids.split(","));
    }

    @Override
    public Integer deleteSecond(String ids) {
        return directoryMapper.deleteSecond(ids.split(","));
    }

    @Override
    public Integer deleteDirectory(String ids) {
        return directoryMapper.deleteDirectory(ids.split(","));
    }

    @Override
    public Integer deleteS_Directory(String ids) {
        return directoryMapper.deleteS_Directory(ids.split(","));
    }

    @Override
    public Integer updateParent(Integer id, String name) {
        return directoryMapper.updateParent(id,name);
    }

    @Override
    public Integer updateSecond(Integer id, String name, Integer pid) {
        return directoryMapper.updateSecond(id,pid,name);
    }

    @Override
    public Integer updateDirectory(Integer id, Integer pid, String title, String link) {
        return directoryMapper.updateDirectory(id,pid,title,link);
    }

    @Override
    public Integer updateS_Directory(Integer id, Integer sid, String title, String link) {
        return directoryMapper.updateS_Directory(id,sid,title,link);
    }

    @Override
    public ParentDirectory getParentBySid(Integer sid) {
        return directoryMapper.getParentBySid(sid);
    }
}
